package com._4pd.demo.demo;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.Version;

import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
import java.util.HashMap;
import java.util.Map;


public class FreeMarkerMain {
    public static void main(String[] args) throws IOException, TemplateException {

        Configuration cfg = new Configuration(new Version("2.3.23"));

        cfg.setDirectoryForTemplateLoading(new File("/Users/yu/Documents/work/ai-operator/src/main/resources"));
        cfg.setDefaultEncoding("UTF-8");

        Template template = cfg.getTemplate("freemarker/init-table.yaml");

        Map<String, Object> templateData = new HashMap<>();
        Map<String, Object> templateData2 = new HashMap<>();
        templateData2.put("name","Today is a beautiful day");
        templateData.put("test", templateData2);


        StringWriter out = new StringWriter();
        template.process(templateData, out);
        out.flush();
        System.out.println(out.getBuffer().toString());


    }
}
